const LabelService = require('../service/label.service')
// const momentService = require('../service/moment.service')

class labelController {
  // 1、新增标签
  async create(ctx, next) {
    const { id } = ctx.user
    const { name } = ctx.request.body
    console.log(name)
    const result = await LabelService.create(name)
    ctx.body = {
      code: 0,
      message: '创建标签成功',
      data: result,
    }
  }
  // 展示标签列表list
  async list(ctx, next) {
    const { offset, size } = ctx.query
    const result = await LabelService.queryList(offset, size)
    ctx.body = {
      code: 0,
      message: '创建标签成功',
      data: result,
    }
  }
  // 删除标签
  async remove(ctx,next){
  const { labelId } = ctx.params
  console.log(labelId)
    const result = await LabelService.remove(labelId)
    // console.log(result)
    ctx.body = {
      code: 0,
      message: '删除成功',
      data: result,
    }
  }
  // 修改标签
  async update(ctx,next){
   
        const { labelId } = ctx.params
        const {name} = ctx.request.body
        const result = await LabelService.updteById(name,labelId)
        //    console.log(result)
        ctx.body = {
          code: 0,
          data: result,
        }
  }
}

module.exports = new labelController()
